package com.design01_builder.pattern03_abstractFactory;

import com.design01_builder.pattern03_abstractFactory.factory.AppliancesFactory;
import com.design01_builder.pattern03_abstractFactory.factory.HisenseFactory;
import com.design01_builder.pattern03_abstractFactory.product.AbstractFreezer;
import com.design01_builder.pattern03_abstractFactory.product.AbstractTV;

import static java.lang.Thread.sleep;

/**
 * @ClassName Client
 * @Description TODO
 * @Author zhangjunhao
 * @DATE 2023/9/3 0:27
 */
public class Client  {

    public AbstractTV getAbstractTV() {
        return abstractTV;
    }

    public void setAbstractTV(AbstractTV abstractTV) {
        this.abstractTV = abstractTV;
    }

    public AbstractFreezer getAbstractFreezer() {
        return abstractFreezer;
    }

    public void setAbstractFreezer(AbstractFreezer abstractFreezer) {
        this.abstractFreezer = abstractFreezer;
    }

    private AbstractTV abstractTV;

    private AbstractFreezer abstractFreezer;

    public Client(AppliancesFactory appliancesFactory) {
        //使用抽象工厂来生产
        this.abstractTV = appliancesFactory.createTV();
        this.abstractFreezer = appliancesFactory.createFreezer();
    }

    public static void main(String[] args) {
        //实例化具体的工厂
        Client client = new Client(new HisenseFactory());
        //获取产品
        AbstractTV abstractTV = client.getAbstractTV();
        AbstractFreezer abstractFreezer = client.getAbstractFreezer();
        System.out.println(abstractTV);
        System.out.println(abstractFreezer);
    }

}
